#!/usr/bin/env ruby

LKP_SRC = ENV['LKP_SRC'] || File.dirname(File.dirname(File.realpath($PROGRAM_NAME)))

require "#{LKP_SRC}/lib/statistics"
require "#{LKP_SRC}/lib/string_ext"
require "#{LKP_SRC}/lib/array_ext"
require "#{LKP_SRC}/lib/tests/stats"

stats = LKP::Stats.new

while (line = $stdin.gets)
  line = line.resolve_invalid_bytes

  case line
  when /^(.+? ).*\[(passed)\]/
    # srp/002 (File I/O ... and login (mq)) [passed]
    stats.add_test_result line, $1.to_s, $2
  when /^(.+? ).*\[(failed)\]/
    stats.add_test_result line, $1.to_s, $2
  when /^(.+? ).*\[(not run)\]/
    # srp/003 (File I/O ... and login (sq)) [not run]
    stats.add_test_result line, $1.to_s, $2
  when /^(.+?\/\*\*\*).*\[(not run)\]/
    stats.add_test_result line, $1.to_s, $2
  end
end

stats.dump
